
<script type="text/javascript">

$(function(){
		   
	$('#formEscola').ajaxForm({
		dataType: 'json',
		beforeSubmit: function() {
			if( $("#txtIdAluno").val()!="" && $("#txtIdProfessor").val()!="" ){
				
				if( $("#txtIdAluno").val() == $("#txtIdProfessor").val() ){
					$.jAlert('O ID aluno tem que ser diferente do professor!', '', '');
					return false;
				}
			}
			if( $("#formEscola").validate().form()==false )
			return false;
		},
		success: function(responseText, statusText) {
			if(responseText.sucesso){
				$.jAlert(responseText.mensagem, '', function(result) {
					listaDados();															 
				});
			}else{
				$.jAlert(responseText.mensagem, '');
			}
		}

	})
	
	$.ajax({
		type:"POST",
		url:"actions/escolaEditAction.php",
		dataType:"json",
		success: function(data, textStatus, request){
			$("#txtFone1").val(data['telefone1']);
			$("#txtDiretor").val(data['diretor']);
			$("#txtFone2").val(data['telefone2']);
			$("#txtFacebook").val(data['facebook']);
			$("#txtWebPage").val(data['webpage']);
			$("#txtTwitter").val(data['twitter']);
			$("#txtEmail").val(data['email']);
			
			$("#txtIdAluno").val(data['id_aluno']);
			$("#txtIdProfessor").val(data['id_professor']);
			
			//carrega o componente mudar senha
			$("#cpMudarSenha").load("componentes/mudarSenhaEscolas.php?id="+data['id_escola']);
		}	
	});	
	
	
	$("#content").css("height","600px");
	
	$("#txtFone1").mask("(99)9999-9999");
	$("#txtFone2").mask("(99)9999-9999");
	
	
})	

function mudarSenha(){
	$('#mudar_senha').dialog({show: "blind", hide: "explode", width:532, height:240, resizable:false});
}

</script>

<style>

	a{color:#333;}

</style>

<div id="formularios">

<fieldset style="height:420px;width:800px;padding:10px;">
        <legend>
            <img src="../images/topoPaginas/Icon_Voce_Menu.png"/>
        </legend>
        <div id="btnSairForms">
        <a href="/?pg=home_escola" title="Sair" style="border:0;">
        	<img src="images/btnOutros/btnSairForms.png"/>
        </a>
        </div>
        <div align="center"> 
        
        <form action="actions/atualizaDadosEscola.php" method="post" id="formEscola" name="formEscola">
        	<table width="592" border="0">
              <tr>
                <td width="270"><span id="title">Telefone 1:</span><span style="color:#F00;"> *</span><br />
                  <input name="txtFone1" type="text"  id="txtFone1" size="30" maxlength="30" class="required"/></td>
                <td width="38">&nbsp;</td>
                <td width="270"><span id="title">E-mail:</span><span style="color:#F00;"> *</span><br />
                  <input name="txtEmail" type="text"  id="txtEmail" size="30" class="required email"/></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td><span id="title">Telefone 2:</span><br />
                  <input name="txtFone2" type="text"  id="txtFone2" size="30" maxlength="30"/></td>
                <td>&nbsp;</td>
                <td><span id="title">Facebook</span><br />
                <input name="txtFacebook" type="text"  id="txtFacebook" size="30" maxlength="30"/></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td><span id="title">Diretor(a)</span>:<span style="color:#F00;"> *</span><br />
                  <input name="txtDiretor" type="text"  id="txtDiretor" size="30" maxlength="30" class="required"/></td>
                <td>&nbsp;</td>
                <td><span id="title">Web Page:</span><br />
                <input name="txtWebPage" type="text"  id="txtWebPage" size="30"/></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td><span id="title">Twitter:</span><br />
                <input name="txtTwitter" type="text"  id="txtTwitter" size="30"/></td>
                <td>&nbsp;</td>
                <td><span id="title">Link Youtube:</span><br />
                <input name="txtLink" type="text" id="txtLink" size="40"/></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td><label><span id="title">ID Professor:</span></label><br />
                <input name="txtIdProfessor" type="text" id="txtIdProfessor" size="30"/></td>
                <td>&nbsp;</td>
                <td><span id="title">ID Aluno</span><br />
                <input name="txtIdAluno" type="text" id="txtIdAluno" size="30"/></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
            </table>

           </form> 
      </div>
    </fieldset>
    
    <div style="position:relative;width:800px;height:40px;text-align:right;padding-right:10px;font-size:10px;color:#F00;">
    	* Campos de preenchimento Obrigatório    
    </div>
    
    <div style="position:relative;width:800px;height:40px;text-align:center;">
    	<a href="javascript:void(0);" onclick="mudarSenha();" title="Mudar Senha" style="border:0;text-decoration:none;padding-left:12px;">
            <img src="images/btnOutros/btnMudarSenha.png"/>
        </a>
        &nbsp;&nbsp;
        <a href="javascript:void(0);" title="Salvar Alterações" onclick="$('#formEscola').submit()" style="border:0;text-decoration:none;padding-left:12px;">
            <img src="images/btnOutros/btnSalvar.png" />
        </a>
    </div>

</div>


<!-- -----------Mudar Senha Componente------------- -->
<div id="cpMudarSenha" style="display:none;"></div>
<!-- -----------Mudar Senha Componente------------- -->